" 行号设置
set number
set relativenumber

" 语法高亮设置
if has('syntax')  
	syntax enable 
	syntax on 
endif

" 高亮光标所在行
set cursorline

" 允许使用鼠标
set mouse=a
" set hidden
set background=dark

" 半透明
highlight Normal guibg=NONE ctermbg=None


" 不拓展tab为空格
set noexpandtab

" 终端真色
set termguicolors


" tab设置
set tabstop=4
set shiftwidth=4
set softtabstop=4

" 自动缩进
set autoindent

" 打开 C/C++ 语言缩进优化
set cindent

" Windows 禁用 ALT 操作菜单（使得 ALT 可以用到 Vim里）
set winaltkeys=no

" 设置分隔符可见
set list
set listchars=tab:\|\ ,trail:▫

" 翻动时上下留出4行
set scrolloff=4

" 关闭功能键超时检测
set ttimeoutlen=0
set notimeout

" 显示光标位置
set ruler

" 设置右下方分屏
set splitright
set splitbelow

" 高亮搜索内容
set hlsearch

" 查找输入时动态增量显示查找结果
set incsearch

" 显示当前命令
set showcmd

" tab补全命令
set wildmenu

" 搜索是忽略大小写，智能判断大小写
set ignorecase
set smartcase

" 编码设置
if has('multi_byte')
	" 内部工作编码
	set encoding=utf-8

	" 文件默认编码
	set fileencoding=utf-8

	" 打开文件时自动尝试下面顺序的编码
	set fileencodings=ucs-bom,utf-9,gbk,gb18030,big5,euc-jp,latin1
endif

" 允许 Vim 自带脚本根据文件类型自动设置缩进等
if has('autocmd')
	filetype plugin indent on
endif
set shortmess+=c
set completeopt=longest,noinsert,menuone,noselect,preview
set linebreak

" 显示匹配的括号
set showmatch

" 显示括号匹配的时间
set matchtime=2

" 延迟绘制
set lazyredraw

" 设置代码折叠
if has('folding')
	" 允许代码折叠
	set foldenable

	" 代码折叠默认使用缩进
	set fdm=indent

	" 默认打开所有缩进
	set foldlevel=99
endif

" 设置 tags：当前文件所在目录往上向根目录搜索直到碰到 .tags 文件
" 或者 Vim 当前目录包含 .tags 文件
set tags=./.tags;,.tags

" 如遇Unicode值大于255的文本，不必等到空格再折行
set formatoptions+=m

" 合并两行中文时，不在中间加空格
set formatoptions+=B

" 文件换行符，默认使用 unix 换行符
set ffs=unix,dos,mac

" 备份文件设置
silent !mkdir -p ~/.config/nvim/tmp/backup
"silent !mkdir -p ~/.config/nvim/tmp/sessions
set backupdir=~/.config/nvim/tmp/backup
set directory=~/.config/nvim/tmp/backup

" undo文件设置
silent !mkdir -p ~/.config/nvim/tmp/undo
if has('persistent_undo')
	set undofile
	set undodir=~/.config/nvim/tmp/undo,.
endif

" 开启自动
set wrap
set whichwrap=b,s,<,>,[,]
set backspace=indent,eol,start
set textwidth=0

" 文件搜索和补全时忽略下面扩展名
set suffixes=.bak,~,.o,.h,.info,.swp,.obj,.pyc,.pyo,.egg-info,.class

set wildignore=*.o,*.obj,*~,*.exe,*.a,*.pdb,*.lib "stuff to ignore when tab completing
set wildignore+=*.so,*.dll,*.swp,*.egg,*.jar,*.class,*.pyc,*.pyo,*.bin,*.dex
set wildignore+=*.zip,*.7z,*.rar,*.gz,*.tar,*.gzip,*.bz2,*.tgz,*.xz    " MacOSX/Linux
set wildignore+=*DS_Store*,*.ipch
set wildignore+=*.gem
set wildignore+=*.png,*.jpg,*.gif,*.bmp,*.tga,*.pcx,*.ppm,*.img,*.iso
set wildignore+=*.so,*.swp,*.zip,*/.Trash/**,*.pdf,*.dmg,*/.rbenv/**
set wildignore+=*/.nx/**,*.app,*.git,.git
set wildignore+=*.wav,*.mp3,*.ogg,*.pcm
set wildignore+=*.mht,*.suo,*.sdf,*.jnlp
set wildignore+=*.chm,*.epub,*.pdf,*.mobi,*.ttf
set wildignore+=*.mp4,*.avi,*.flv,*.mov,*.mkv,*.swf,*.swc
set wildignore+=*.ppt,*.pptx,*.docx,*.xlt,*.xls,*.xlsx,*.odt,*.wps
set wildignore+=*.msi,*.crx,*.deb,*.vfd,*.apk,*.ipa,*.bin,*.msu
set wildignore+=*.gba,*.sfc,*.078,*.nds,*.smd,*.smc
set wildignore+=*.linux2,*.win32,*.darwin,*.freebsd,*.linux,*.android
